function main() {
    debugger
    let matterCodeList = Object.values(this.state.extraParams.matter_code.id).join(',');
    let sourceUnitId = this.state.extraParams.unit_id;
    let targetUnitIdList = this.$$("tree_panel_43e5cy").$$getSelection().selectedKeys
        .map(id => id.replace('unit', '')).join(',');

    batchCopyUnitMatterRel(targetUnitIdList, matterCodeList, sourceUnitId,this)
}

function batchCopyUnitMatterRel(targetUnitIdList, matterCodeList, sourceUnitId,self) {

    var jsonParams = {
        "sourceUnitId": sourceUnitId,
        "targetUnitIdList": targetUnitIdList,
        "matterCodeList": matterCodeList
    };
    api.DATA_SOURCE_EXECUTE("ds_api:ff806e4d-4670-49be-a186-8f39172ceb9d", "api", [], [], JSON.stringify(jsonParams)).then((res) => {
        notifyParentAndClose(self)
    }).catch(err => {
        console.log(err);
    });
}

function notifyParentAndClose(self) {
    const pageRenderElement = self.$$root().$parent.$parent.$parent;
    if (window.parent) {
        window.parent.postMessage(
            JSON.stringify({ event: "close-dialog", param: { XXX: "test" } }),
            "*"
        );
    }
}
